﻿#pragma once

#include <QWidget>
#include "ui_DeMuxerAndPlayWindow.h"
#include <QCloseEvent>
#include <QString>
#include <thread>
#include <chrono>
#include <QDebug>
#include "../../sdl/render/IVideoRenderView.h"
#include "../codec/YDecoder.h"

/// <summary>
/// 解封装后解码渲染案例
/// </summary>
class DeMuxerAndPlayWindow : public QWidget
{
	Q_OBJECT

public:
	DeMuxerAndPlayWindow(QWidget *parent = nullptr);
	~DeMuxerAndPlayWindow();

	void OnDraw();

protected:
	// 重写关闭事件处理函数
	void closeEvent(QCloseEvent* event) override;
signals:
	void updateSize(int videoWidth, int videoHeight);

public slots:
	void onSelectedFile();
	void onStartPlay();
	void onUpdateSize(int videoWidth, int videoHeight);
private:
	Ui::DeMuxerAndPlayWindow ui;
	QString fileName;
	std::unique_ptr<std::thread> renderThread;
	bool isRunning = false;
	IVideoRenderView* renderView = nullptr;
};
